﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        OdbcConnection Conexao = new OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};SERVER='localhost';DATABASE='bdrascontrol';USER='root';PASSWORD='';");

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string VarLogin = txtLogin.Text.Replace(@"'", @"''");
            string VarSenha = txtSenha.Text.Replace(@"'", @"''");

            OdbcCommand Comando = new OdbcCommand("Select * From formulario Where LOGIN='" + VarLogin + "' And SENHA='" + VarSenha + "'", Conexao);
            Conexao.Open();

            OdbcDataReader Objloc = Comando.ExecuteReader();

            if (!Objloc.Read())
            {
                lblResposta.Text = "Login ou senha inválido";
            }
            else
            {
                Session["logado"] = Objloc["CodigoForm"];
                Response.Redirect("home.aspx");
            }
            Objloc.Close();
            Conexao.
            Close();  
        }
    }
}